'''
@Company: TWL
@Author: xue jian
@Email: xuejian@kanzhun.com
@Date: 2020-06-02 16:39:15
'''
class Solution:
    def sumNums(self, n: int) -> int:
        re = 0
        count = 0
        tmp = n+1
        while tmp:
            rem = tmp % 2
            if rem:
                re += n<<count
            tmp >>= 1
            count += 1

            
        return re>>1



if __name__ == "__main__":
    s = Solution()
    print(s.sumNums(6))